from rest_framework import serializers
from report.models import WorkoutPlan, Exercise, WorkoutPlanExercise


class ExerciseSerializer(serializers.ModelSerializer):
    class Meta:
        model = Exercise
        fields = '__all__'


class WorkoutPlanExerciseSerializer(serializers.ModelSerializer):

    exercise = ExerciseSerializer(read_only=True)
    class Meta:
        model = WorkoutPlanExercise
        fields = ['exercise', 'sets', 'reps', 'order']



class WorkoutPlanSerializer(serializers.ModelSerializer):

    exercises = WorkoutPlanExerciseSerializer(many=True, source='workoutplanexercise_set')
    class Meta:
        model = WorkoutPlan
        fields = ['id', 'title', 'description', 'difficulty',
                  'total_duration', 'rest_time', 'exercises', 'created_at']